home *** CD-ROM | disk | FTP | other *** search
/ Aminet 50 / Aminet 50 (2002)(GTI - Schatztruhe)[!][Aug 2002].iso / Aminet / text / edit / tecoc-146.lha / docjr.c < prev    next >
C/C++ Source or Header  |  1991-07-05  |  2KB  |  67 lines

  1. /*****************************************************************************
  2.  
  3.     DoCJR()
  4.  
  5.     This function contains the code that's common to the C, J and R
  6. commands.  It is called by ExeC, ExeJ and ExeR only.
  7.  
  8. *****************************************************************************/
  9.  
  10. #include "zport.h"        /* define portability identifiers */
  11. #include "tecoc.h"        /* define general identifiers */
  12. #include "defext.h"        /* define external global variables */
  13. #include "deferr.h"        /* define identifiers for error messages */
  14.  
  15. DEFAULT DoCJR(HowFar)        /* do C, J or R stuff */
  16. LONG HowFar;            /* positive or negative displacement */
  17. {
  18.     LONG    InRange;
  19.     BOOLEAN    ColonMod;
  20.  
  21. #if DEBUGGING
  22.     static char *DbgFNm = "DoCJR";
  23.     sprintf(DbgSBf,"HowFar = %ld", HowFar);
  24.     DbgFEn(2,DbgFNm,DbgSBf);
  25. #endif
  26.  
  27.     ColonMod = (CmdMod & COLON);        /* is it :C, :J, or :R? */
  28.     CmdMod &= ~COLON;            /* clear : flag */
  29.  
  30.     InRange = -1;                /* -1 means SUCCESS in TECO */
  31.     if (HowFar > 0) {
  32.         if ((GapEnd+HowFar) > EBfEnd) {
  33.             InRange = 0;        /* 0 means FAILURE in TECO */
  34.         } else {
  35.             MEMMOVE(GapBeg, GapEnd+1, HowFar);
  36.             GapBeg += HowFar;
  37.             GapEnd += HowFar;
  38.         }
  39.     } else {
  40.         if ((GapBeg+HowFar) < EBfBeg) {
  41.             InRange = 0;        /* 0 means FAILURE in TECO */
  42.         } else {
  43.             GapBeg += HowFar;
  44.             GapEnd += HowFar;
  45.             MEMMOVE(GapEnd+1, GapBeg, -(HowFar));
  46.         }
  47.     }
  48.  
  49.     if (ColonMod) {                /* if colon modifier */
  50.         DBGFEX(2,DbgFNm,"PushEx");
  51.         return PushEx(InRange, OPERAND);
  52.     } else {
  53.         if (InRange == 0) {        /* if out-of-bounds */
  54.             ErrChr(ERR_POP, *CBfPtr);
  55.             DBGFEX(2,DbgFNm,"FAILURE");
  56.             return FAILURE;
  57.         }
  58.     }
  59.  
  60.     CmdMod = '\0';                /* clear modifiers flags */
  61.     EStTop = EStBot;            /* clear expression stack */
  62.  
  63.     DBGFEX(2,DbgFNm,"SUCCESS");
  64.  
  65.     return SUCCESS;
  66. }
  67.